
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState({
      defaultStep: state => state.app.defaultStep,
      workFlow: state => state.positionDetail.workFlow
    })
  },
  methods: {
    positionStep (step) {
      if (step) {
        if (this.$i18n.locale === 'zh') {
          return this.defaultStep.find(item => item.step === step).name
        } else {
          return this.defaultStep.find(item => item.step === step).name_en
        }
      }
    },
    positionStatus (step, status) {
      if (this.workFlow.length && step) {
        let findObj = this.workFlow.find(flow => flow.step === step)
        if (!findObj) return '-'
        if (!status) status = findObj.statusList[0].code
        findObj = findObj.statusList.find(statusItem => statusItem.code === status)
        if (!findObj) return '-'
        if (this.$i18n.locale === 'zh') {
          return findObj.name
        } else {
          return findObj.name_en
        }
      }
    },
    currentStep (step) {
      let index = this.defaultStep.findIndex(item => item.step === step)
      return index - 1
    }
  }
}
